package day02;

import java.util.Scanner;

/**无序数组分解为n个有序子数组并返回n
 * @author tongchen
 * @create 2022-11-21 23:15
 */
class Day01_1 {

    public static void main(String[] args) {
        //输入
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //创建数组1
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; ++i) {
            arr[i] = scan.nextInt();
        }
        //创建数组2

        int count=0;
        test(arr,count);
        System.out.println();
    }

    //编写方法
    public static int test(int[] arr, int count) {
        int n= arr.length-1;
      int index=0;//创建下标
        while(index<n){
            if(arr[index]>arr[index+1]){

                while(index<n&&arr[index]>arr[index+1]){
                    index++;
                }
                //结束后i++ count++
                index++;
                count++;
            }
            else if(arr[index]==arr[index+1]){
                index++;
            }
            else{
                while (index<n&&arr[index]<arr[index+1]){
                    index++;

                }
                count++;
                index++;
            }
        }
        return count;
    }

}

